//
//  InputTableViewController.m
//  11-23
//
//  Created by Mac OS on 15-11-23.
//
//

#import "InputTableViewController.h"

@interface InputTableViewController()<UITextFieldDelegate>
{
    UITextField *tf;
}
@end

@implementation InputTableViewController

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    tf = [[UITextField alloc]initWithFrame:CGRectMake(10, 10, self.view.frame.size.width -20, 24)];
    tf.clearButtonMode = UITextFieldViewModeAlways;
    tf.text = self.tel;
    tf.delegate = self;
    //[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"aaaaaa"];
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [tf becomeFirstResponder];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
    //UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"aaaaaa"];
    [cell addSubview:tf];
    return cell;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    //return 键 实现保存操作
    [textField resignFirstResponder];
    [self.delegate inputFinished:textField.text];
    return YES;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
